<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: RecursiveHTTPFetcher</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">RecursiveHTTPFetcher</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/rails/railties/lib/commands/plugin_rb.html">
                vendor/rails/railties/lib/commands/plugin.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000013">download</a>&nbsp;&nbsp;
      <a href="#M000014">fetch</a>&nbsp;&nbsp;
      <a href="#M000015">fetch_dir</a>&nbsp;&nbsp;
      <a href="#M000012">links</a>&nbsp;&nbsp;
      <a href="#M000009">ls</a>&nbsp;&nbsp;
      <a href="#M000008">new</a>&nbsp;&nbsp;
      <a href="#M000011">pop_d</a>&nbsp;&nbsp;
      <a href="#M000010">push_d</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">quiet</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(urls_to_fetch, level = 1, cwd = &quot;.&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 858</span>
858:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">urls_to_fetch</span>, <span class="ruby-identifier">level</span> = <span class="ruby-value">1</span>, <span class="ruby-identifier">cwd</span> = <span class="ruby-value str">&quot;.&quot;</span>)
859:     <span class="ruby-ivar">@level</span> = <span class="ruby-identifier">level</span>
860:     <span class="ruby-ivar">@cwd</span> = <span class="ruby-identifier">cwd</span>
861:     <span class="ruby-ivar">@urls_to_fetch</span> = <span class="ruby-identifier">urls_to_fetch</span>.<span class="ruby-identifier">to_a</span>
862:     <span class="ruby-ivar">@quiet</span> = <span class="ruby-keyword kw">false</span>
863:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="#M000013" class="method-signature">
          <span class="method-name">download</span><span class="method-args">(link)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 897</span>
897:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">download</span>(<span class="ruby-identifier">link</span>)
898:     <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;+ #{File.join(@cwd, File.basename(link))}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@quiet</span>
899:     <span class="ruby-identifier">open</span>(<span class="ruby-identifier">link</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">stream</span><span class="ruby-operator">|</span>
900:       <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@cwd</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">link</span>)), <span class="ruby-value str">&quot;wb&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
901:         <span class="ruby-identifier">file</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">stream</span>.<span class="ruby-identifier">read</span>)
902:       <span class="ruby-keyword kw">end</span>
903:     <span class="ruby-keyword kw">end</span>
904:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="#M000014" class="method-signature">
          <span class="method-name">fetch</span><span class="method-args">(links = @urls_to_fetch)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000014-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 906</span>
906:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">links</span> = <span class="ruby-ivar">@urls_to_fetch</span>)
907:     <span class="ruby-identifier">links</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
908:       (<span class="ruby-identifier">l</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\/$/</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">links</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@urls_to_fetch</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">fetch_dir</span>(<span class="ruby-identifier">l</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">download</span>(<span class="ruby-identifier">l</span>)
909:     <span class="ruby-keyword kw">end</span>
910:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000015" class="method-detail">
        <a name="M000015"></a>

        <div class="method-heading">
          <a href="#M000015" class="method-signature">
          <span class="method-name">fetch_dir</span><span class="method-args">(url)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000015-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 912</span>
912:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fetch_dir</span>(<span class="ruby-identifier">url</span>)
913:     <span class="ruby-ivar">@level</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
914:     <span class="ruby-identifier">push_d</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">url</span>)) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@level</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
915:     <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">stream</span><span class="ruby-operator">|</span>
916:       <span class="ruby-identifier">contents</span> =  <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">read</span>
917:       <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">links</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">contents</span>))
918:     <span class="ruby-keyword kw">end</span>
919:     <span class="ruby-identifier">pop_d</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@level</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
920:     <span class="ruby-ivar">@level</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
921:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">links</span><span class="method-args">(base_url, contents)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 886</span>
886:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">links</span>(<span class="ruby-identifier">base_url</span>, <span class="ruby-identifier">contents</span>)
887:     <span class="ruby-identifier">links</span> = []
888:     <span class="ruby-identifier">contents</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/href\s*=\s*\&quot;*[^\&quot;&gt;]*/i</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">link</span><span class="ruby-operator">|</span>
889:       <span class="ruby-identifier">link</span> = <span class="ruby-identifier">link</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/href=&quot;/i</span>, <span class="ruby-value str">&quot;&quot;</span>)
890:       <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/svnindex.xsl$/</span>
891:       <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^(\w*:|)\/\//</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">link</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^\./</span>
892:       <span class="ruby-identifier">links</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">base_url</span>, <span class="ruby-identifier">link</span>)
893:     <span class="ruby-keyword kw">end</span>
894:     <span class="ruby-identifier">links</span>
895:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">ls</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 865</span>
865:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ls</span>
866:     <span class="ruby-ivar">@urls_to_fetch</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">url</span><span class="ruby-operator">|</span>
867:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">url</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^svn:\/\/.*/</span>
868:         <span class="ruby-node">`svn ls #{url}`</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;\n&quot;</span>).<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;/#{entry}&quot;</span>} <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
869:       <span class="ruby-keyword kw">else</span>
870:         <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">stream</span><span class="ruby-operator">|</span>
871:           <span class="ruby-identifier">links</span>(<span class="ruby-value str">&quot;&quot;</span>, <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">read</span>)
872:         <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
873:       <span class="ruby-keyword kw">end</span>
874:     <span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">flatten</span>
875:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">pop_d</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 882</span>
882:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pop_d</span>
883:     <span class="ruby-ivar">@cwd</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-ivar">@cwd</span>)
884:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000010" class="method-detail">
        <a name="M000010"></a>

        <div class="method-heading">
          <a href="#M000010" class="method-signature">
          <span class="method-name">push_d</span><span class="method-args">(dir)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000010-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 877</span>
877:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">push_d</span>(<span class="ruby-identifier">dir</span>)
878:     <span class="ruby-ivar">@cwd</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@cwd</span>, <span class="ruby-identifier">dir</span>)
879:     <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-ivar">@cwd</span>)
880:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>